/**
 * Copyright (c) 2005-2012 springside.org.cn
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 */
package com.thon.commons.utils;

import java.util.Map;
import java.util.Map.Entry;

/**
 *集合转换工具
 */
public class CollectionToCollection {

	public static final Integer[] strToIntArr(String types2, String string) {
		
		Integer[] typeArray2 = null;
		String[] strArr = types2.split(string);
		if(strArr==null)
		{
			typeArray2= null;
		
		}
		else
		{
			typeArray2 = new Integer[strArr.length];
			for(int i=0;i<strArr.length;i++)
			{
				typeArray2[i] = Integer.parseInt(strArr[i]);
			}
		}
		return typeArray2;
		
	}
	
	
	public static final Integer findIndex(String str[], String strQuery) {
		for(int i=0;i<str.length;i++)
		{
			if(str[i].equals(strQuery))
				return i; 
		}
		return -1;
	}
	
	public static final Integer findIndex(String str[], Integer strQuery) {
		for(int i=0;i<str.length;i++)
		{
			if(strQuery.equals(Integer.parseInt(str[i])))
				return i; 
		}
		return -1;
	}
	
	
	public static final Integer findIndex(Integer num[], Integer queryNum) {
		for(int i=0;i<num.length;i++)
		{
			if(num[i].equals(queryNum))
				return i; 
		}
		return -1;
	}
	
	public static final Integer findIndex(Integer num[], String strQuery) {
		for(int i=0;i<num.length;i++)
		{
			if(num[i].equals(Integer.parseInt(strQuery)))
				return i; 
		}
		return -1;
	}
	
	public static final Integer findIndex(Map<?,?> map,Integer QueryId) {
		int i=0;	
		for (Entry<?, ?> entry : map.entrySet()) {
			if(QueryId.equals(entry.getKey()))
				return i;			
				i++;
	  }		
		return -1;
	}
}
